<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <div>
        <h1>商城登录页面</h1>
        <form id="login_form">
            用户名:<input type="text" name="userName"><br>
            密码:<input type="password" name="userPassword"><br>
            <button type="button" id="register">注册</button>
            <button type="button" id="login_btn">登录</button>
        </form>
    </div>
    <script src="style/jquery-3.3.1.js"></script>
    <script>
        $("#login_btn").click(function (){
            $.ajax({
                type:"post",
                url:"UserController/login",
                data:$("#login_form").serialize(),
                dataType:"json",
                success:function (json){
                    if(json.message=="登录成功"){
                        location.href = "buba/index.html";
                    }else{
                        alert(json.message);
                    }
                }
            });
        })
        $("#register").click(function (){
            location.href="register.html";
        })
    </script>
</body>
</html>